﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = $.request("keyValue");
    $(function () {
        initControl();
        if (!!keyValue) {
            $.ajax({
                url: "/WorkFlow/WFCategory/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                }
            });
        }
    });
    function initControl() {
        $("#parentId").renderSelect({
            url: "/WorkFlow/WFCategory/GetTreeSelectJson",
        });
    }
    function submitForm(index) {
        if (!$('#form1').formValid()) {
            return false;
        }
        $.submitForm({
            url: "/WorkFlow/WFCategory/SubmitForm",
            param: $("#form1").formSerialize(),
            success: function (rsp) {
                if (rsp.message) {
                    $.modalAlert(rsp.message, rsp.state);
                }

                if (rsp.state == "success") {
                    $.currentWindow().$("#gridList").trigger("reloadGrid");
                    top.layer.close(index);
                }
            }
        })
    }
</script>
<form id="form1">
    <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
        <div style="padding-top: 20px; margin-right: 30px;">
            <table class="form">
                <tr>
                    <th class="formTitle">父级</th>
                    <td class="formValue">
                        <select id="parentId" name="parentId" class="form-control required">
                            <option value="0">顶级</option>
                        </select>
                    </td>
                    <th class="formTitle">编码</th>
                    <td class="formValue">
                        <input id="id" name="id" type="hidden" />
                        <input id="code" name="code" type="text" class="form-control required" placeholder="唯一编码" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">名称</th>
                    <td class="formValue">
                        <input id="name" name="name" type="text" class="form-control required" placeholder="名称" />
                    </td>
                    <th class="formTitle">排序</th>
                    <td class="formValue">
                        <input id="sortIdx" name="sortIdx" type="number" class="form-control required" placeholder="排序号" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle" valign="top" style="padding-top: 5px;">备注
                    </th>
                    <td class="formValue" colspan="3">
                        <textarea id="remark" name="remark" class="form-control" style="height: 60px;"></textarea>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</form>
